package controller;

import model.User;
import model.UserDao;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class Test {
    public static void main(String[] args) throws IOException {
//        UserDao userDao = new UserDao();
//        User user = userDao.selectByUserName("zhangsan");
//
//
//        System.out.println("您的用户名和密码为"+": "+user.getUsername()+user.getPassword());

        //创建socket
        DatagramSocket socket = new DatagramSocket(8080);
        while(true){
            //创建packet 用于接收数据
            DatagramPacket packet = new DatagramPacket(new byte[1024],1024);

            System.out.println("前");
            socket.receive(packet);
            System.out.println("后");
            //将收到的消息转为字符串
            String res = new String(packet.getData(),
                    0,
                    packet.getLength(),
                    "utf-8");

            System.out.println(res);


        }
    }
}
